
#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "ztbox.h"
#include "ztboxpluginloader.h"
#include <QKeyEvent>
#include <QMainWindow>
#include <QMouseEvent>
#include <QWidget>
#include <src/ui/widgets/animationtext/animationtext.h>

QT_BEGIN_NAMESPACE
class QPropertyAnimation;
QT_END_NAMESPACE
namespace Ui {
    class MainWindow;
}
class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    bool compareExtensions(ZTBoxInterface *extension);
    void initPluginCompleter();
    
    void showWidget(QWidget *widget);
    QPropertyAnimation *animation;
    QWidget *emptyWidget;
    AnimationText *animationHolder;
    
private:
    Ui::MainWindow *ui;
    QList<ZTBoxInterface*> listWidgets;
    ZTBoxInterface *currentExtension;

    // QWidget interface
protected:
    void mousePressEvent(QMouseEvent *event) override {
        if (event->button() == Qt::LeftButton) {
            m_dragStartPos = event->pos();
            m_dragging = true;
        }
    };
    void mouseReleaseEvent(QMouseEvent *event) override {
        if (event->button() == Qt::LeftButton) {
            m_dragging = false;
        }
    };
    void mouseMoveEvent(QMouseEvent *event) override {
        if (m_dragging) {
            move(event->globalPos() - m_dragStartPos);
        }
    };

private:
    bool m_dragging = false;
    QPoint m_dragStartPos;

    // QWidget interface
protected:
    void mouseDoubleClickEvent(QMouseEvent *event) override;;

    // QWidget interface
protected:
    void keyPressEvent(QKeyEvent *event) override;

    // QWidget interface
protected:
    void showEvent(QShowEvent *event) override {
//        started = true;
    };
};

#endif // MAINWINDOW_H

